<?php

namespace app\mini\controller\v1\client;

use app\common\logic\BannerLogic;
use app\common\logic\GoodsLogic;
use app\common\logic\ShopGoodsLogic;
use app\common\logic\ShopNewLogic;
use app\mini\controller\Common;
use app\common\logic\ShopLogic;
use think\Env;
use think\Request;
use think\response\Json;

class Index extends Common
{
    public $ShopLogic;
    public $ShopNewLogic;

    public $ShopGoodsLogic;

    public $GoodsLogic;
    public $BannerLogic;

    public function __construct(Request $request = null)
    {
        parent::__construct($request);
        $this->ShopLogic      = new ShopLogic();
        $this->ShopNewLogic      = new ShopNewLogic();
        $this->ShopGoodsLogic = new ShopGoodsLogic();
        $this->GoodsLogic     = new GoodsLogic();
        $this->BannerLogic     = new BannerLogic();
    }

    /**
     * 首页轮播图
     * @return Json
     */
    public function banner(): Json
    {
        $res = $this->exception(function () {
            return $this->BannerLogic->index(request()->param());
        });
        return $this->response($res);
    }



    /**
     * 轮播图详情
     * @return Json
     */
    public function banner_detail(): Json
    {
        $res = $this->exception(function () {
            return $this->BannerLogic->banner_detail(request()->param());
        });
        return $this->response($res);
    }


    /**
     * 商家分页列表
     * @return Json
     */
    public function index(): Json
    {
        $res = $this->exception(function () {
            return $this->ShopNewLogic->index(request()->param());
        });
        return $this->response($res);
    }



    /**
     * 商家详情
     * @return Json
     */
    public function info(): Json
    {
        $res = $this->exception(function () {
            return $this->ShopNewLogic->info(request()->param());
        });
        return $this->response($res);
    }



    /**
     * 商家产品列表
     * @return Json
     */
//    public function shopGoods(): Json
//    {
//        $res = $this->exception(function () {
//            return $this->ShopGoodsLogic->list(request()->param());
//        });
//        return $this->response($res);
//    }

    /**
     * 产品详情
     * @return Json
     */
    public function goodsInfo(): Json
    {
        $res = $this->exception(function () {
            $params                 = request()->param();
            $params['goods_status'] = $this->ShopGoodsLogic->enable;
            return $this->ShopGoodsLogic->info($params);
        });
        return $this->response($res);
    }


}
